$(function(){
	var record = 0;
	$("#learnrecord").hover(function(){
		if(record == '0'){
			url = GAODUNER.path+'/Account/get_studentrecord?callback=?';
			$.getJSON(url,{},function(data){
				//var data=eval("("+data+")");
				if(data.status == 1){
					html = '';
					if(data.data){
						for(i=0;i<data.data.length;i++){
							var str=data.data[i].coursewarepart+' -- '+data.data[i].courseware+' -- '+data.data[i].course;
							var name = cutstr(str,30);
							//html+='<a href="'+GAODUNER.path+'/class/play/pid/'+data.data[i].courseware_part_id+'" title="'+str+'">'+name+'</a>';
							if(data.data[i].istasks==0){
								html+='<a href="'+GAODUNER.path+'/class/play/pid/'+data.data[i].courseware_part_id+'" title="'+str+'">'+name+'</a>';
							}else{
								html+='<a href="'+GAODUNER.path+'/task/play/pid/'+data.data[i].courseware_part_id+'" title="'+str+'">'+name+'</a>';
							}
							//html+='<a href="'+GAODUNER.path+'/class/play/pid/'+data.data[i].courseware_part_id+'">'+data.data[i].coursewarepart+'</a>';
						}
					}else{
						html+='暂无学习记录！';
					}
					$("#showrecord").html(html);
					record ++ ;
				}
			});
		}
	});
})

//js截取字符串，中英文都能用
//如果给定的字符串大于指定长度，截取指定长度返回，否者返回源字符串。
//字符串，长度
function cutstr(str,len){
	var str_length = 0;
	var str_len = 0;
	str_cut = new String();
	str_len = str.length;
	for(var i = 0;i<str_len;i++){
		a = str.charAt(i);
		str_length++;
		if(escape(a).length > 4){
			//中文字符的长度经编码之后大于4
			str_length++;
		}
		str_cut = str_cut.concat(a);
		if(str_length>=len){
			str_cut = str_cut.concat("...");
			return str_cut;
		}
	}
	//如果给定字符串小于指定长度，则返回源字符串；
	if(str_length<len){
		return str;
	}
}